package com.example.tb.controller;

import com.example.tb.entity.BiOpeningRecord;
import com.example.tb.entity.PageBean;
import com.example.tb.service.*;
import com.example.tb.utils.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
* @Description: 开标文件展示
* @Author: yaodada
* @Date: 2024/1/4
*/
@Slf4j
@RestController
@RequestMapping("/statusDisplay")
public class StatusDisplayController {


    @Resource
    private PageService pageService;


    /**
     * 客户信息列表（分页查询功能）
     */
    @RequestMapping(value="/findByPage")
    public ResponseResult<Object> reportInfoPage(@RequestParam(value="pageCode",defaultValue = "1",required = false)int pageCode,
                                                 @RequestParam(value="pageSize",defaultValue = "2",required = false)int pageSize,
                                                 HttpServletRequest request){
        // 封装分页数据
        Map<String,Object> conMap = new HashMap<String,Object>();
        conMap.put("bid",request.getParameter("bid"));
        conMap.put("itemNum",request.getParameter("itemNum"));
        conMap.put("bidOpeningTime",request.getParameter("bidOpeningTime"));
        conMap.put("dataSource",request.getParameter("dataSource"));
        conMap.put("fbName",request.getParameter("fbName"));
        conMap.put("fbNum",request.getParameter("fbNum"));
        conMap.put("turn",request.getParameter("turn"));
        conMap.put("projectUnit",request.getParameter("projectUnit"));
        conMap.put("tendererName",request.getParameter("tendererName"));
        conMap.put("discountRate",request.getParameter("discountRate"));
        conMap.put("bidRate",request.getParameter("bidRate"));
        conMap.put("remark",request.getParameter("remark"));
        conMap.put("isWin",request.getParameter("isWin"));
        conMap.put("limitedPrice",request.getParameter("limitedPrice"));

        PageBean<BiOpeningRecord> byPage = pageService.findByPage(pageCode, pageSize, conMap);
        if (0 == byPage.getBeanList().size()){
            log.info("分页查询  error  {}","参数为空");
            return ResponseResult.error(ResponseResult.ResponseCode.PARAMETRIC_NULL_ANOMALY);
        }else {
            log.info("分页查询  success");
            return ResponseResult.success(byPage);
        }
    }
}
